all files / src/ game.actions.ts

100% Statements 47/47
100% Branches 0/0
100% Functions 15/15
100% Lines 47/47
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164                                                    85×                 13×                     17× 17×             16× 16×                   46×                                                               19×                             27×                          
import { Card, Phase, CardPattern } from './game.interfaces';
 
 
export interface Action {
    type: string;
}
//------------------------------------------------
export const REGISTER_PLAYER = 'REGISTER_PLAYER';
export interface RegisterPlayer extends Action {
    id: string
}
export function registerPlayer(id: string): RegisterPlayer {
    return {
        type: REGISTER_PLAYER,
        id
    };
}
//------------------------------------------------
export const SET_DECK = 'SET_DECK';
export interface SetDeck extends Action {
    deck: CardPattern[]
}
export function setDeck(deck: CardPattern[]): SetDeck {
    return {
        type: SET_DECK,
        deck
    };
}
//------------------------------------------------
export const DEAL_CARD_TO_PLAYER = 'DEAL_CARD_TO_PLAYER';
export interface DealCardToPlayer extends Action {
    id: string
}
export function dealCardToPlayer(id: string): DealCardToPlayer {
    return {
        type: DEAL_CARD_TO_PLAYER,
        id
    };
}
 
//------------------------------------------------
export const DEAL_CARD_TO_STOCK = 'DEAL_CARD_TO_STOCK';
export interface DealCardToStock extends Action {}
 
export function dealCardToStock(): DealCardToStock {
    return {
        type: DEAL_CARD_TO_STOCK
    };
}
 
//------------------------------------------------
export const BID = 'BID';
export interface Bid extends Action {
    bid: number,
    pass: boolean,
    player: string
}
export function bid(player: string, bid: number): Bid {
    const pass = bid === 0;
    return {
        type: BID,
        bid, player, pass
    };
}
//------------------------------------------------
export const INCREASE_BID = 'INCREASE_BID';
export interface IncreaseBid extends Bid {}
export function increaseBid(player: string, bid: number): IncreaseBid {
    const pass = bid === 0;
    return {
        type: INCREASE_BID,
        bid, player, pass
    };
}
 
//------------------------------------------------
export const SET_PHASE = 'SET_PHASE';
export interface SetPhase extends Action {
    phase: Phase
}
export function setPhase(phase: Phase): SetPhase {
    return {
        type: SET_PHASE,
        phase
    };
}
//------------------------------------------------
export const SHARE_STOCK = 'SHARE_STOCK';
export interface ShareStock extends Action {
    card: CardPattern,
    player: string,
    targetPlayer: string
}
export function shareStock(player: string, card: CardPattern, targetPlayer: string): ShareStock {
    return {
        type: SHARE_STOCK,
        card, player, targetPlayer
    };
}
//------------------------------------------------
export const ASSIGN_STOCK = 'ASSIGN_STOCK';
export interface AssignStock extends Action {}
export function assignStock(): AssignStock {
    return {
        type: ASSIGN_STOCK
    };
}
//------------------------------------------------
export const INITIALIZE_BATTLE = 'INITIALIZE_BATTLE';
export function initializeBattle(): Action {
    return {
        type: INITIALIZE_BATTLE
    };
}//------------------------------------------------
export const INITIALIZE_BIDDING = 'INITIALIZE_BIDDING';
export function initializeBidding(): Action {
    return {
        type: INITIALIZE_BIDDING
    };
}
//------------------------------------------------
export const THROW_CARD = 'THROW_CARD';
export interface ThrowCard extends Action {
    card: CardPattern,
    player: string
}
export function throwCard(card: CardPattern, player: string): ThrowCard {
    return {
        type: THROW_CARD,
        card, player
    };
}
//------------------------------------------------
export const CALCULATE_BATTLE_RESULT = 'CALCULATE_BATTLE_RESULT';
export interface CalculateBattleResult extends Action {
}
export function calculateBattleResult(): CalculateBattleResult {
    return {
        type: CALCULATE_BATTLE_RESULT
    };
}
//------------------------------------------------
export const DECLARE_BOMB = 'DECLARE_BOMB';
export interface DeclareBomb extends Action {
    player: string
}
export function declareBomb(player: string): DeclareBomb {
    return {
        type: DECLARE_BOMB,
        player
    };
}
//------------------------------------------------
export const FINALIZE_TRICK = 'FINALIZE_TRICK';
export interface FinalizeTrick extends Action {
    trickWinner: string
}
export function finalizeTrick(trickWinner: string): FinalizeTrick {
    return {
        type: FINALIZE_TRICK,
        trickWinner
    };
}